﻿Imports System.Data.SqlClient

Public Class clsFAVORITOS
    Public Sub ENVIAR_A_FAVORITOS(ByVal IDCITRA As Integer)

        Dim sql As String = "Insert Into FAVORITOS " & _
                       "VALUES (" & _
                       "@IDCITRA," & _
                       "@USUARIO," & _
                       "@FECHA)"



        Dim cnConns As New SqlConnection
        cnConns.ConnectionString = CitraConnection

        Dim Commands As New SqlCommand(sql, cnConns)

        Commands.Parameters.AddWithValue("IDCITRA", IDCITRA)
        Commands.Parameters.AddWithValue("USUARIO", UsuarioActivo)
        Commands.Parameters.AddWithValue("FECHA", Now())

        cnConns.Open()
        Dim RowsAffected As Integer
        Try
            RowsAffected = Commands.ExecuteNonQuery
            If RowsAffected > 0 Then
                cnConns.Close()
            Else
                If cnConns.State = ConnectionState.Open Then
                    cnConns.Close()
                End If
            End If
        Catch ex As Exception
            If cnConns.State = ConnectionState.Open Then
                cnConns.Close()
            End If
        End Try
    End Sub
    Public Sub QUITAR_DE_FAVORITOS(ByVal IDCITRA As Integer)
        Call SetSqlCitra("DELETE FROM FAVORITOS WHERE USUARIO='" & UsuarioActivo & "' AND IDCITRA=" & IDCITRA)
    End Sub
End Class
